#include <iostream>
using namespace std;

const int N = 2e5 + 10;
int n;
int a[N];
int dp[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    int sum = -101;

    for (int i = 1; i <= n; i++)
    {
        dp[i] = max(dp[i - 1], 0) + a[i];
        sum = max(sum, dp[i]);
    }

    cout << sum << endl;
}